package com.yhn.bff.driver.exception;


import cn.dev33.satoken.exception.NotLoginException;
import cn.dev33.satoken.exception.NotPermissionException;
import com.yhn.hxds.common.model.BaseResponse;
import com.yhn.hxds.common.model.ResultUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 用户鉴权异常处理器
 *
 * @author yhnyhn123
 */
@RestControllerAdvice
@Slf4j
public class ExceptionHandler {

    @org.springframework.web.bind.annotation.ExceptionHandler(NotLoginException.class)
    public BaseResponse<?> loginExceptionHandler(NotLoginException e) {
        log.error("RuntimeException", e);
        return ResultUtils.error("您必须登录后才能访问");
    }

    @org.springframework.web.bind.annotation.ExceptionHandler(NotPermissionException.class)
    public BaseResponse<?> permissionExceptionHandler(NotPermissionException e) {
        log.error("RuntimeException", e);
        return ResultUtils.error("抱歉，您没有此功能的权限");
    }



}
